package com.parkinglot.management.common;

import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.AlipayTradePrecreateRequest;
import com.alipay.api.response.AlipayTradePrecreateResponse;
import com.baidu.aip.ocr.AipOcr;
import org.json.JSONObject;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;

@Configuration
public class CommonConfigure {
    private static final String APP_ID = "18971629";
    private static final String API_KEY = "vctw3hBLvksldz6VmzQ1GwBE";
    private static final String SECRET_KEY = "kdu6hKbQxbNSB7l5TMcDjMj5xrOU7PQ0";

    @Bean
    public AipOcr apiOcr(){
        return new AipOcr(APP_ID,API_KEY,SECRET_KEY);
    }

    public static void main(String[] args) throws IOException, AlipayApiException {
//        AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
//        // 调用接口
//        String path = "C:\\Users\\63144\\Desktop\\1.jpg";
//        File file = new File(path);
//        FileInputStream fileInputStream = new FileInputStream(file);
//        byte[] bytes = new byte[fileInputStream.available()];
//        JSONObject res = client.plateLicense(path, new HashMap<String, String>());
//        JSONObject words_result = (JSONObject) res.get("words_result");
//        System.out.println(words_result.get("number"));
//        Date date = new Date();
//        System.out.println(date.getTime());
    }



}
